银河麒麟V10系统的 postgresql/postgis完整部署

您所在的位置:网站首页 chkconfig 银河麒麟 银河麒麟V10系统的 postgresql/postgis完整部署

银河麒麟V10系统的 postgresql/postgis完整部署

2023-12-12 00:13| 来源: 网络整理| 查看: 265

一、posgresql部署1、安装前可以先进行用户以及用户组的配置,方便后面进行授权(通过编译安装也需要,后续步骤会体现)。用户配置# 新增用户组 groupadd postgres # 创建用户组内用户 useradd -g postgres postgres # 修改用户密码 passwd postgres

我得密码:·123qwer

2、通过yum安装

如果用户通过yum能匹配导相应版本,可以直接进行安装。进行检索安装

yum search postgres* # 选择对应版本进行安装 yum -y install postgresql # 安装相应程序包 yum -y install qt5-qtbase-postgresql # 安装相应程序包

银河麒麟V10系统的 postgresql/postgis完整部署_sql

安装完成后可以进行相应的检查

rpm -qa | grep postgres # 检查PostgreSQL 是否已经安装 rpm -qal | grep postgres # 检查PostgreSQL 安装位置 rpm -e #卸载

银河麒麟V10系统的 postgresql/postgis完整部署_数据库_02

3、编译安装

3.1、 安装软件准备基于此情况,我们首先需要准备相应的安装包内容,下载地址参照 postgresql v10.0下载地址:https://www.postgresql.org/ftp/source/v10.0/

postgresql源码编译时的 ./configure 需要此软件,安装方式。右键选择在终端打开

[root@localhost ~]# yum install readline-devel

银河麒麟V10系统的 postgresql/postgis完整部署_sql_03

最好安装下openssl-devel,因为安装timescaledb时会提示这个未安装(一般情况也可以不安装)

[root@localhost ~]# yum install openssl-devel

银河麒麟V10系统的 postgresql/postgis完整部署_数据库_04

 3.2 文件包编译

将下载好的文件放入文件目录下,这里我放在postgresql目录下

[root@localhost home]# mkdir postgresql #创建postgresql目录[root@localhost home]# cd /home/postgresql #切换到postgresql目录下[root@localhost home]# tar -zvxf postgresql-10.0.tar.gz #解压文件[root@localhost postgresql]# cd postgresql-10.0 #切换到postgresql-10.0目录下[root@localhost postgresql-10.0]# ./configure #执行文件[root@localhost postgresql-10.0]# make[root@localhost postgresql-10.0]# make install

3.3、 安装完成后进行数据库data配置进行配置,先创建好相应的目录文件

mkdir -p /usr/local/pgsql/data # 创建数据存储目录

chown -R postgres:postgres /usr/local/pgsql/data # 用户/用户组目录授权

银河麒麟V10系统的 postgresql/postgis完整部署_sql_05

初始化数据库

su - postgres

银河麒麟V10系统的 postgresql/postgis完整部署_postgresql_06

 initdb -D /usr/local/pgsql/data

pg_ctl -D /usr/local/pgsql/data -l logfile startcreatedb postgispsql postgis

这里可以查看数据库安装好后的对应版本

select version();

接着需要设置相应的环境变量,方便程序读取到指定内容

# 编辑用户下的环境变量配置文件

vi ./.bash_profile

输入如下内容:

LD_LIBRARY_PATH=/usr/local/pgsql/lib export LD_LIBRARY_PATH PATH=/usr/local/pgsql/bin:$PATH export PATH export PGDATA=/usr/local/pgsql/data

银河麒麟V10系统的 postgresql/postgis完整部署_sql_07

 编辑相应的数据库配置文件,修改postgresql.conf与pg_hba.conf

cd /usr/local/pgsql/data # 查找listen_addresses在postgresql.conf文件中的位置并显示行号 cat postgresql.conf | grep -n listen_addresses # 编辑postgresql.conf文件,修改默认'localhost' 为'*' vi postgresql.conf # 编辑IPv4 local connections: 追加一行,如图所示 vi pg_hba.conf # 修改完成后可以进行服务的重启 pg_ctl restart 此处截图为pg_hba.conf追加配置

  

设置服务自动启动

chkconfig --list

 

二、PostGIS安装部署

此时发现postgis在麒麟系统环境内并没有提供相关yum安装包,那么则进行所需运行环境程序的编译安装即可。

1、安装编译时环境

设置安装相应编译文件后也需要对相应的文件进行用户的授权,否则运行时会显示该用户无权限,或者文件不存在。运行 create extension *会出现错误

1.1、proj4安装

银河麒麟V10系统的 postgresql/postgis完整部署_sql_08

[root@localhost home]# wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz # 下载文件

银河麒麟V10系统的 postgresql/postgis完整部署_数据库_09

[root@localhost ~]# cd /home [root@localhost home]# tar -zxvf proj-4.9.3.tar.gz[root@localhost home]# cd proj-4.9.3[root@localhost proj-4.9.3]# ./configure --prefix=/data-postgis/pgsql/plugin/proj[root@localhost proj-4.9.3]# make[root@localhost proj-4.9.3]# make install[root@localhost proj-4.9.3]# echo "/data-postgis/pgsql/plugin/proj/lib" > /etc/ld.so.conf.d/proj-4.9.3.conf[root@localhost proj-4.9.3]# ldconfig1.2、geos

银河麒麟V10系统的 postgresql/postgis完整部署_sql_10

[root@localhost home]# wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2[root@localhost home]# tar -jxf geos-3.6.1.tar.bz2

  [root@localhost home]# cd geos-3.6.1 

[root@localhost geos-3.6.1]# ./configure --prefix=/data-postgis/pgsql/plugin/geos[root@localhost geos-3.6.1]# make[root@localhost geos-3.6.1]# make install[root@localhost geos-3.6.1]# echo "/data-postgis/pgsql/plugin/geos/lib" > /etc/ld.so.conf.d/geos-3.6.1.conf[root@localhost geos-3.6.1]# ldconfig

银河麒麟V10系统的 postgresql/postgis完整部署_sql_11

 

银河麒麟V10系统的 postgresql/postgis完整部署_sql_12

1.3、gdal

银河麒麟V10系统的 postgresql/postgis完整部署_postgresql_13

 

[root@localhost home]# wget http://download.osgeo.org/gdal/2.1.2/gdal-2.1.2.tar.gz[root@localhost home]# tar -zxvf gdal-2.1.2.tar.gz[root@localhost home]# cd gdal-2.1.2[root@localhost gdal-2.1.2]# ./configure --prefix=/data-postgis/pgsql/plugin/gdal[root@localhost gdal-2.1.2]# make[root@localhost gdal-2.1.2]# make install[root@localhost gdal-2.1.2]# echo "/data-postgis/pgsql/plugin/gdal/lib" > /etc/ld.so.conf.d/gdal-2.1.2.conf[root@localhost gdal-2.1.2]# ldconfig2. 编译postgis安装包2.1 编译安装[root@localhost home]# wget http://postgis.net/stuff/postgis-2.5.3dev.tar.gz

  [root@localhost home]# tar -zxvf postgis-2.5.3dev.tar.gz

[root@localhost home]# cd postgis-2.5.3dev[root@localhost postgis-2.5.3dev]# ./configure --prefix=/data-postgis/pgsql/plugin/postgis --with-pgconfig=/data-postgis/pgsql/bin/pg_config --with-geosconfig=/data-postgis/pgsql/plugin/geos/bin/geos-config --with-gdalconfig=/data-postgis/pgsql/plugin/gdal/bin/gdal-config --with-projdir=/data-postgis/pgsql/plugin/proj[root@localhost postgis-2.5.3dev]# make[root@localhost postgis-2.5.3dev]# make install

这里完成需要重新创建一个新的postgis_25数据库,详细参见postgresql部署3部分的-初始化数据库。否则启动/重启后一直提示找不到数据库。

2.2 安装扩展插件# 切换postgres用户 su - postgres # 登录PG数据库 psql # 创建一个数据库 create database postgis; # 切换到postgis库中 \c postgis # 显示一下扩展模块 \dx

运行如下sql内容

CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology; --CREATE EXTENSION fuzzystrmatch; --CREATE EXTENSION postgis_tiger_geocoder

  做到这里就完成的插件的安装。

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3